]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Add optional datetime parameter to notifications
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 26 Feb 2017 23:14:09 +0000 (00:14 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 27 Feb 2017 19:04:08 +0000 (20:04 +0100)
Since the last notification redesign, we've been showing the time a
notification was received in the calendar drop-down. However as the
time is in fact added by the NotificationSection, it is actually the
time a notification was added to the list. Usually that difference is
not significant, except when previously received notifications are
restored on startup.
In order to be able to address those cases, we need a time that is
associated with the notification itself, so add a datetime property
that defaults to the current time, but may be set from an optional
parameter as well.

https://bugzilla.gnome.org/show_bug.cgi?id=775799

js/ui/calendar.js
js/ui/messageTray.js

index 2ed812613581bfe17abf679cf50a4d98819a1094..70252e2ec3e0104d50557f499fec18aa553467d1 100644 (file)
@@ -946,8 +946,8 @@ const NotificationSection = new Lang.Class({
                !Main.sessionMode.isGreeter;
     },
 
-    _createTimeLabel: function() {
-        let label = Util.createTimeLabel(new Date());
+    _createTimeLabel: function(datetime) {
+        let label = Util.createTimeLabel(datetime);
         label.style_class = 'event-time',
         label.x_align = Clutter.ActorAlign.END;
         return label;
@@ -970,13 +970,13 @@ const NotificationSection = new Lang.Class({
 
     _onNotificationAdded: function(source, notification) {
         let message = new NotificationMessage(notification);
-        message.setSecondaryActor(this._createTimeLabel());
+        message.setSecondaryActor(this._createTimeLabel(notification.datetime));
 
         let isUrgent = notification.urgency == MessageTray.Urgency.CRITICAL;
 
         let updatedId = notification.connect('updated', Lang.bind(this,
             function() {
-                message.setSecondaryActor(this._createTimeLabel());
+                message.setSecondaryActor(this._createTimeLabel(notification.datetime));
                 this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.actor.mapped);
             }));
         let destroyId = notification.connect('destroy', Lang.bind(this,
index 4f1ab7feaaa09d5174e8c7df7b53cea2adf0ef94..fe1b4d8e75f0246c5f9679f8d674e58c0e717f0d 100644 (file)
@@ -368,6 +368,7 @@ const Notification = new Lang.Class({
                                         secondaryGIcon: null,
                                         bannerMarkup: false,
                                         clear: false,
+                                        datetime: null,
                                         soundName: null,
                                         soundFile: null });
 
@@ -375,6 +376,11 @@ const Notification = new Lang.Class({
         this.bannerBodyText = banner;
         this.bannerBodyMarkup = params.bannerMarkup;
 
+        if (params.datetime)
+            this.datetime = params.datetime;
+        else
+            this.datetime = GLib.DateTime.new_now_local();
+
         if (params.gicon || params.clear)
             this.gicon = params.gicon;